Skip to content

fix: parse PostgreSQL DDL key and identity options - #2929

Merged
manticore-projects merged 1 commit into
JSQLParser:masterfrom
minleejae:fix/postgresql-ddl-key-options-20261115
Nov 15, 2026
Merged

manticore-projects merged 1 commit into
JSQLParser:masterfrom
minleejae:fix/postgresql-ddl-key-options-20261115

Conversation

@minleejae

@minleejae minleejae commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

PostgreSQL accepts the following DDL forms, which failed to parse:

CREATE INDEX ix ON t (CAST(n AS bigint), EXTRACT(YEAR FROM d));
CREATE TABLE child PARTITION OF parent
    FOR VALUES WITH (REMAINDER 3, MODULUS 8);
CREATE TABLE ids (id bigint GENERATED ALWAYS AS IDENTITY (UNLOGGED));
  • With Dialect.POSTGRESQL, read bare CAST/EXTRACT index and partition keys as their
    existing expression nodes. Keep key attributes and require parentheses around
    arithmetic expressions. A following opening parenthesis distinguishes a call from
    identifiers such as extract.
  • Read HASH bound names in either order for CREATE and ATTACH PARTITION, retaining
    the modulus/remainder AST fields and canonical MODULUS-first output.
  • Represent identity sequence LOGGED/UNLOGGED as Sequence.ParameterType values,
    including ALTER COLUMN ADD IDENTITY. Reject repeated persistence options and keep
    standalone sequence syntax intact.

References: CREATE INDEX,
CREATE TABLE,
ALTER TABLE.

Validation:

  • Seven positive regression cases fail on master f880f35; the negative/control
    cases also run against that baseline.
  • JDK 17 ./gradlew clean check jar: PASS; 16,456 tests, zero failures/errors,
    25 existing skips. New regression class: 26/26 PASS. Grammar ambiguity, Checkstyle,
    PMD, SpotBugs, Spotless and coverage verification all pass. Local execution uses
    an external init script only to cap heaps and pin the formatter ratchet to f880f35.
  • GitHub CI on cea764b: Gradle Check and Maven Verify pass on Linux, macOS and
    Windows; grammar ambiguity and Codacy pass.
  • Nine SQL cases parse, deparse and reparse with the PostgreSQL dialect. All nine
    deparser outputs execute successfully on PostgreSQL 18.6, with catalog postchecks
    for index expressions, partition bounds and identity sequence persistence/options.
  • The SQL survey covers 80 DDL cases and two adjacent probes (164 default/explicit
    observations). It changes nine failing observations and preserves every previously parsed observation, including AST,
    canonical SQL, deparsing and table traversal results.

Bare CAST/EXTRACT keys require parser.withDialect(Dialect.POSTGRESQL), consistent
with the existing typed PostgreSQL function-key path.

AI assistance: prepared with OpenAI Codex.

Preserve CAST/EXTRACT key expressions with the PostgreSQL dialect,
accept both HASH bound name orders and retain identity persistence
as typed sequence parameters. Add positive, negative and identifier
regressions without widening standalone sequence syntax.
@manticore-projects
manticore-projects merged commit 5f6fb83 into JSQLParser:master Nov 15, 2026
10 checks passed
@manticore-projects

Copy link
Copy Markdown
Contributor

thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants